package pojo;
import java.util.Objects;

public class Student {
    private Integer sno;
    private String name;
    private Double score;

    public Student(Integer sno, String name, Double score) {
        this.sno = sno;
        this.name = name;
        this.score = score;
    }

    public Integer getSno() {
        return sno;
    }

    public void setSno(Integer sno) {
        this.sno = sno;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getScore() {
        return score;
    }

    public void setScore(Double score) {
        this.score = score;
    }

    @Override
    public boolean equals(Object o) {
        // 1. 自反性检查
        if (this == o) return true;

        // 2. 类型和空值检查
        if (o == null || getClass() != o.getClass()) return false;

        // 3. 类型转换
        Student other = (Student) o;

        // 4. 比较关键属性（假设学号sno是唯一标识）
        return Objects.equals(this.sno, other.sno);
    }

    @Override
    public String toString() {
        return "Student{" +
                "sno=" + sno +
                ", name='" + name + '\'' +
                ", score=" + score +
                '}';
    }
}
